package hxy.ecnu.lambda;

import java.util.function.Consumer;

public class LambdaTest1 {

	public static void main(String[] args) {
//		String[] a=System.out::println;
		new Thread(new Runnable() {

			@Override
			public void run() {
				System.out.println("Java正常使用线程方式");

			}
		}).start();

		new Thread(() -> {
			System.out.println("Java Lambda使用线程方式");
		}).start();
		Consumer c = new Consumer() {
			@Override
			public void accept(Object o) {
				System.out.println(o);
			}
		};
		Consumer c1 = (o) -> {
			System.out.println(o);
		};
		Consumer c2 = (o) -> System.out.println(o);
		Consumer c3 = System.out::println;
		c.accept("haode ");
		c1.accept("keyi");
		//执行完c2后再执行c3的Accept方法
	    c2.andThen(c3).accept("test1");
	    c2.andThen(c2).andThen(c2).andThen(c2).andThen(c2).andThen(c3).accept("test2");
	    Consumer f = System.out::println;
	    Consumer f2 = n -> System.out.println(n + "-F2");
	}

}
